package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.GoodsType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GoodsTypeDao {

    @Insert("insert into goodstype(goodsTypeId,goodsTypeName,updateTime,insertTime,status,`index`,parentGoodsTypeId) " +
            "values(#{goodsTypeId},#{goodsTypeName},#{updateTime},#{insertTime},#{status},#{index},#{parentGoodsTypeId})")
    int insert(GoodsType goodstype);

    @Select("select * from goodstype order by `index`")
    List<GoodsType> query();

    @Select("select * from goodstype where goodsTypeId=#{goodsTypeId}")
    GoodsType queryById(String goodsTypeId);

    @Delete("delete from goodstype where goodsTypeId=#{goodsTypeId}")
    int deleteById(String goodsTypeId);

    @Select("select count(0) from goodstype where parentGoodsTypeId=#{id}")
    Integer queryByParentCount(String id);

}
